package santeclair.connexion.webservice.impl;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import santeclair.connexion.bean.trame.aller.pecAlmerys.FluxPecAlmerysAnnulation;
import santeclair.connexion.bean.trame.aller.pecAlmerys.FluxPecAlmerysCreation;
import santeclair.connexion.bean.trame.aller.pecAlmerys.ResultatGenerationTramePecAlmerys;
import santeclair.connexion.dto.FluxPecAlmerys.FluxPecAlmerysAnnulationDto;
import santeclair.connexion.dto.FluxPecAlmerys.FluxPecAlmerysCreationDto;
import santeclair.connexion.service.echanges.PecAlmerysAnnulationService;
import santeclair.connexion.service.echanges.PecAlmerysCreationService;
import santeclair.connexion.service.trame.impl.GenerationPojoAnnulationPecAlmerysServiceImpl;
import santeclair.connexion.service.trame.impl.GenerationPojoCreationPecAlmerysServiceImpl;
import santeclair.connexion.webservice.GestionTramePecAlmerysWebService;

@Service
public class GestionTramePecAlmerysWebServiceImpl implements GestionTramePecAlmerysWebService {

    @Autowired
    @Qualifier("generationPojoAnnulationPecAlmerysService")
    private GenerationPojoAnnulationPecAlmerysServiceImpl generationPojoAnnulationPecAlmerysService;

    @Autowired
    @Qualifier("generationPojoCreationPecAlmerysService")
    private GenerationPojoCreationPecAlmerysServiceImpl generationPojoCreationPecAlmerysService;

    @Autowired
    private PecAlmerysCreationService pecAlmerysCreationService;

    @Autowired
    private PecAlmerysAnnulationService pecAlmerysAnnulationService;

    public ResultatGenerationTramePecAlmerys genererTrameCreation(FluxPecAlmerysCreationDto fluxBatchCreationDto) throws IOException {

        FluxPecAlmerysCreation fluxPecAlmerysCreation = (FluxPecAlmerysCreation) generationPojoCreationPecAlmerysService.initPojo(fluxBatchCreationDto);

        ResultatGenerationTramePecAlmerys resultatGenerationTramePecAlmerys = pecAlmerysCreationService.genererTrame(fluxPecAlmerysCreation);

        return resultatGenerationTramePecAlmerys;
    }

    public ResultatGenerationTramePecAlmerys genererTrameAnnulation(FluxPecAlmerysAnnulationDto fluxBatchAnnulationDto) throws IOException {

        FluxPecAlmerysAnnulation fluxPecAlmerysAnnulation = (FluxPecAlmerysAnnulation) generationPojoAnnulationPecAlmerysService.initPojo(fluxBatchAnnulationDto);

        ResultatGenerationTramePecAlmerys resultatGenerationTramePecAlmerys = pecAlmerysAnnulationService.genererTrame(fluxPecAlmerysAnnulation);

        return resultatGenerationTramePecAlmerys;
    }
}
